home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Source.bin
/
ZOrderUtils.java
< prev
Wrap
Text File
|
1998-08-21
|
4KB
|
128 lines
package symantec.itools.util;
import java.awt.Container;
import java.awt.Component;
// 07/19/97 RKM Created this class
// 07/20/97 RKM Changes to make the boolean calculated
// 08/01/97 RKM Added assumeZOrder function
// 09/20/97 RKM Updated to new zorder for MRJ 2.0
// 11/05/97 LAB Fixed assumeZOrder such that is behaves as the comments suggest.
// (Addresses Mac Bug #9990)
/**
* Determines the order components are drawn: first-to-last or last-to-first.
*/
public final class ZOrderUtils
{
/**
* All-static class, do not use.
*/
private ZOrderUtils() {
}
/**
* Determines if the first component is drawn over the second componnet.
*/
public static boolean isFirstDrawnOverSecond()
{
return m_IsFirstDrawnOverSecond;
}
/**
* Determines if the second component is drawn over the first componnet.
*/
public static boolean isSecondDrawnOverFirst()
{
return !m_IsFirstDrawnOverSecond;
}
/**
* Reverses the order of all components in a container.
* @param container the container with the components to reverse
*/
public static void reverseContainersZOrder(Container container)
{
//Get a list of the current components in the container
Component[] components = container.getComponents();
//Remove all of the components
container.removeAll();
//Reverse the order the components are in
int numComponents = components.length;
for (int i = components.length - 1;i >= 0;i--)
{
Component component = components[i];
container.add(component);
//???RKM??? What's faster, instanceof and cast or catching ClassCastException???
if (component instanceof Container)
reverseContainersZOrder((Container)component);
}
}
/**
* Reverses the order of all components in a container if the current environment
* doesn't draw them as assumed.
* @param container the container with the components to reverse, as needed
* @param assumedFirstDrawnOverSecond the assumed drawing order. If the actual
* drawing order matches this, then no component reversal is needed
*/
public static boolean assumeZOrder
(Container container,
boolean assumedFirstDrawnOverSecond)
{
if (assumedFirstDrawnOverSecond == isFirstDrawnOverSecond())
return false;
reverseContainersZOrder(container);
return true;
}
static private boolean m_IsFirstDrawnOverSecond;
static
{
String OSName = System.getProperty("os.name");
//???RKM??? We should verify and move these into the OS class
if (OSName.startsWith("S") || // SunOS, Solaris
OSName.startsWith("Kona") || // Kona (Mr. Coffee)
OSName.startsWith("AIX") || // AIX
OSName.startsWith("OSF") ) // OSF
{
m_IsFirstDrawnOverSecond = true;
}
else
{
String javaVendor = System.getProperty("java.vendor");
boolean javaVendorIsNetscape = javaVendor.startsWith("Netscape");
String javaVersion = System.getProperty("java.version");
// Windows Netscape 3.0bx
if (symantec.itools.lang.OS.isWindows() &&
javaVendorIsNetscape && javaVersion.equals("1.02") )
{
m_IsFirstDrawnOverSecond = true;
}
else
{
if (symantec.itools.lang.OS.isMacintosh() &&
(javaVendorIsNetscape || (javaVendor.startsWith("Apple") && !javaVersion.equals("1.02"))))
{
m_IsFirstDrawnOverSecond = true;
}
else
{
m_IsFirstDrawnOverSecond = false;
}
}
}
}
}